package com.itheima.dianming.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.dianming.pojo.domain.StuInterface;
import com.itheima.dianming.pojo.domain.StuProject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface StuInterfaceMapper extends BaseMapper<StuInterface> {

    @Select("<script> select t1.id,\n" +
            "t2.`username` as stu_name,\n" +
            "(select project_name from tb_project where id = project_id) as project_name,\n" +
            "(select interface_name from tb_model_interface where id = interface_id) as interface_name,\n" +
            "t1.response_code,t1.is_ok,t1.create_time,t1.is_down,t1.stu_id,t1.project_id,t1.interface_id \n" +
            "from `tb_stu_interface`  t1 left join tb_stu t2 on t1.`stu_id` = t2.`id`\n" +
            "<where>  " +
            "<if test='projectId!=null'> and t1.project_id = #{projectId} </if>" +
            "<if test='name!=null and name.length()>0'>and t2.`username` = #{name}  </if>" +
            "</where>" +
            "order by t1.stu_id ,t1.interface_id " +
            "</script> ")
    IPage<StuInterface> queryPage(IPage<StuInterface> pageInfo, @Param("name") String name, @Param("projectId") Long projectId);
}
